readline去除换行符
时间: 2023-09-02 15:10:28 浏览: 128
Python 实现文件读写、坐标寻址、查找替换功能
使用fp.readline().replace('\n', '')可以去除readline()读取出的字符串中的换行符。
#### 引用[.reference_title]
- *1* *3* [Python 去除readline()的换行符(\n,\r)](https://blog.csdn.net/u012856866/article/details/119648743)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Python 三种读文件方法read(), readline(), readlines()及去掉换行符\n](https://blog.csdn.net/qq_40109570/article/details/119590307)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文