Detailed map traversal, teach you to master the complex gremlin query debugging method>>>
Python_ Error: typeerror: write() argument must be STR, not int
When running the file write operation, an error is reported: typeerror: write() argument must be STR, not int
Upper Code:
fp = open("1023a.txt","w+")
l = [1023,1024,1025]
fp.writelines(l)
fp.seek(0,0)
fp.read()
fp.close()
The operation effect is as follows:
Cause analysis:
writelines() can pass in both a string and a character sequence, and write the character sequence to a file
note: writelines must pass in a character sequence, not a number sequence
It can be changed as follows:
fp = open("1023b.txt","w+")
l = ["1023","1024","1025"]
fp.writelines(l)
fp.seek(0,0)
fp.read()
fp.close()
The following results are:
Similar Posts:
- Python Exception: TypeError: write() argument must be str, not list
- TypeError: write() argument must be str, not bytes
- [Solved] error: ‘gets’ was not declared in this scope; did you mean ‘fgets’?
- How to read and write multiple files in Python?
- Python TypeError: unbound method a() must be called with A instance as first argument (go…
- [Solved] Python TypeError: sequence item 0: expected str instance, int found
- TypeError: strptime() argument 1 must be str, not bytes
- The solution of typeerror: expected string or buffer
- 6. Zigzag conversion
- [Solved] TypeError: string indices must be integers, not str