For questions about the Python module named sys. This tag is also used for questions relating to the Sys namespace - the root namespace for the Microsoft AJAX Library, which contains all fundamental classes and base classes.
Questions tagged [sys]
1100 questions
-1
votes
1 answer
How can I execute 1TB log file python script in command line
I have a log file which consists the capacity of 1TB. I am uncertain that how to run this python script in the command line. I use the sys library but still my csv data is not added.
Below is my python code.
import re
import sys
from csv import…

Katarina Alves
- 89
- 10
-1
votes
1 answer
Python - if SystaxError
I have problem with this if.
I found I can use in in if-statement.
if "log" in sys.argv[1:]
Syntax Error

Dortík
- 167
- 1
- 7
-1
votes
1 answer
Argparse: what is the difference between "sys.argv[1]" and "args.input"?
I'm learning how to use argparse and it's a labyrinth for me.
I have a code that works: if I run python Test.py . it prints all files in hierarchy using this code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import argparse
import…

Francesco Mantovani
- 10,216
- 13
- 73
- 113
-1
votes
1 answer
Setting parameters for Python based digit puller
I'm trying to make a Python utility that will pull digits from the head or tail of a string. I would like to make the # of digits to pull the second parameter given in the scripts syntax. ex: "script.py string -2" to pull the last 2 digits from the…

jmank
- 1
-1
votes
2 answers
How to display concatenated string on same
Using following code I want to take two strings, concat them and display them on same line using sys.stdin.readline() for input and sys.stdout.write() for output.
import sys
str1 = sys.stdin.readline()
str2 = sys.stdin.readline()
str3 = str1 +…

CH325
- 17
- 5
-1
votes
1 answer
Integer Arguments Error
I'm attempting to write a program that takes two integer arguments. After some research, I've learned that I need to use the int() funtion when defining the arguments. However, I get an error when I try this code:
import sys
a, b =…

Nick F
- 43
- 1
- 7
-1
votes
1 answer
It there difference between `sys.exit()` and `sys.exit(_())`
I am aware of some facts about sys.exit(). However, I have seen some usage of sys.exit(_("some error msg blablabla")), is there any differences between them?

shwsun
- 27
- 4
-1
votes
1 answer
SyntaxError when running program
I have to make a calculator with argv.sys. When I run my code I keep getting this error:
>>> "C:\Users\admin\Desktop\uni\Informatik BW\assignment.py" + rect 0 0 10 10
File "", line 1
"C:\Users\admin\Desktop\uni\Informatik…
-1
votes
1 answer
Using webbrowser module to use Google Maps
i'm just new to python and i want to ask a simple question.
what's the difference between using this code:
import webbrowser, pyperclip, sys
chrome = "C:/Program Files/Google/Chrome/Application/chrome.exe %s"
def…

Lucifer1002
- 59
- 1
- 1
- 5
-1
votes
1 answer
error: initializer element is not constant C
I keep geting
`error: initializer element is not constant
FILE *file = fopen("/sys/class/hwmon/hwmon0/temp1_input", "r");
temperatura.c:19:14: error: expected ‘)’ before string constant
fscanf(file ,"%s", &temp);`;
my entire code looks…

Vid
- 9
- 1
- 5
-1
votes
2 answers
Python:Changing path at the end of if statement
My gui currently has a combo box with the the option of selecting four different file locations. Once its selected every file in that directory will be displayed in a listbox:
def ComboBox(self, event):
current = self.buttonChoice.current()
…

RayBae
- 62
- 10
-1
votes
1 answer
Python Conjecture
recently I have been trying to make a spin-off of Collatz conjecture using python 3.0. The program works as it should with positive integers, but it will not work with negative integers. In the program I check if the number is negative and if so I…

tcwissemann
- 1
- 1
- 4
-1
votes
1 answer
System arguments error in python
I have recently started using sys.argv in python and I am trying the following thing:
import sys
[filename]=sys.argv[0:1]
[NumoflinesToread]=sys.argv[1:2]
[tmax]=sys.argv[2:3]
This takes the first three arguments after the script. I want to add an…

PythonNoob
- 139
- 2
- 7
-1
votes
1 answer
Python: Replace String in a .txt file
import os, sys
pandaFile = open("panda.txt", "w")
pandaRead = pandaFile.read()
if "NOON" in pandaRead:
print("Enter a noon:")
noon = input()
str.replace("NOON",noon)
if "ADJECTIVE" in pandaRead:
print("Enter an adjective:")
…

Yann H.
- 23
- 3
-1
votes
1 answer
Why can I only invoke sys.stdin with a for loop
it seems like I can only invoke it by using a for loop
for line in sys.stdin:
print line
where can I find documentations on how sys methods are structured
I've looked at the official documentation and that really wasn't enough
thanks

demalegabi
- 577
- 6
- 19