Something like this – for each line read into string variable a
:
>>> a = "123,456" >>> b = a.split(",") >>> b ['123', '456'] >>> c = [int(e) for e in b] >>> c [123, 456] >>> x, y = c >>> x 123 >>> y 456
Now you can do what is necessary with x
and y
as assigned, which are integers.
Related Posts:
- How do I copy a file in Python?
- How do I copy a file in Python?
- How to open a file using the open with statement
- Using “with open() as file” method, how to write more than once? [duplicate]
- How to read a file line-by-line into a list?
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- Confused by python file mode “w+”
- File open and close in python
- Do I understand os.walk right?
- FileNotFoundError: [Errno 2] No such file or directory [duplicate]
- How to move a file in Python?
- Python open() gives FileNotFoundError/IOError: Errno 2 No such file or directory
- FileNotFoundError: [Errno 2] No such file or directory
- How can I split and parse a string in Python?
- How to move a file in Python?
- How do you append to a file?
- Writing a list to a file with Python
- Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- How do I copy a file in Python?
- Split a string into 2 in Python
- Split string with multiple delimiters in Python [duplicate]
- How do you split a string in Python with multiple delimiters?
- How do I check whether a file exists without exceptions?
- Call a function from another file?
- Writing a list to a file with Python
- How can I check file size in Python?
- Python list directory, subdirectory, and files
- Where does this come from: -*- coding: utf-8 -*-
- Open file in a relative location in Python
- Why am I getting a FileNotFoundError?
- Python: Write array values into file
- Importing variables from another file?
- How do you split a list into evenly sized chunks?
- How to copy files?
- How to split a string into a list of characters in Python?
- Flask raises TemplateNotFound error even though template file exists
- importing external “.txt” file in python
- Search and replace a line in a file in Python
- How to save a dictionary to a file?
- How to open a file for both reading and writing?
- How do you read a file into a list in Python?
- SSL error : routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
- What is the perfect counterpart in Python for “while not EOF”
- Python 2: AttributeError: ‘list’ object has no attribute ‘strip’
- AttributeError: ‘list’ object has no attribute ‘lower’ gensim
- .write not working in Python
- Creating files and directories via Python
- Pandas split DataFrame by column value
- How to convert a file into a dictionary?
- How to delete a specific line in a file?
- Split function add: \xef\xbb\xbf…\n to my list
- How often does python flush to a file?
- How to open every file in a folder
- TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
- Loading and parsing a JSON file with multiple JSON objects
- How to split elements of a list?
- How to find out whether a file is at its `eof`?
- Python IOError: File not open for reading
- What does random.sample() method in python do?
- (Python) TypeError: ‘float’ object is not subscriptable
- ‘DataFrame’ object has no attribute ‘sort’
- How to check Django version
- How to change the font size on a matplotlib plot
- How can I create a dropdown menu from a List in Tkinter?
- How to find all occurrences of a substring?
- Does “\d” in regex mean a digit?
- How do you use subprocess.check_output() in Python?
- filename.whl is not a supported wheel on this platform
- How to take column-slices of dataframe in pandas
- Python: Get the first character of the first string in a list?
- How to convert string to binary?
- Python error load JSON code of google API
- How do I find the duplicates in a list and create another list with them?
- Get ZeroDivisionError: float division in python
- How do I detect collision in pygame?
- Remove xticks in a matplotlib plot?
- “for line in…” results in UnicodeDecodeError: ‘utf-8’ codec can’t decode byte
- TypeError: string argument without an encoding
- ValueError: cannot index with vector containing NA / NaN values
- How to append multiple values to a list in Python
- How do I do a case-insensitive string comparison?
- How to multiply all integers inside list
- How can I get the named parameters from a URL using Flask?
- How can I from bs4 import BeautifulSoup?
- Pandas OR statement ending in series contains
- TypeError: Invalid dimensions for image data when plotting array with imshow()
- “getaddrinfo failed”, what does that mean?
- pythonw.exe or python.exe?
- How to convert an XML string to a dictionary?
- matplotlib does not show my drawings although I call pyplot.show()
- RuntimeWarning: overflow encountered in ubyte_scalars
- How to throw error and exit with a custom message in python
- What is the difference between random.randint and randrange?
- How do I access my webcam in Python?
- Boolean Series key will be reindexed to match DataFrame index
- Python a &= b meaning?
- TypeError: can only concatenate tuple (not “int”) in Python
- Write a program using integers user_num and x as input, and output user_num divided by x three times
- File “/usr/bin/pip”, line 9, in
from pip import main ImportError: cannot import name main