> For the complete documentation index, see [llms.txt](https://lei-d.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lei-d.gitbook.io/leetcode/python-tips/read-and-write-data-file.md).

# Read and write data file

read

```python
ret = []
filePath = "/home/qewtert/setwtr/test.xyz"
for line in open(filePath, 'r'):
    nums = line.split(".")
    for num in nums:
        i = int(line)
        string
    ret.append(nums)
```

write

```python
filePath = "./result.txt"
resultFile =  open(filePath, 'w')
ret = "12345t"
resultFile.write(ret)
```
