惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - Lunais

恢复 git stash drop 丢失的内容 Git技巧:彻底重置本地仓库与远程同步,同时保留Stash内容 信源编码和信道编码区别 Leetcode scanf 一组数据差值之和最大 5G 3gpp协议 eclipse调试配置 find查找 浮点类型(float、double)在内存中的存储 yield [基础函数]memset用法 linux系统objdump输出动态库.so文件和静态库.a中符号表 python复制删除文件&修改目录&执行bat(wins) Linux C下的正则表达式 kill eclipse C语言之表达式运算整体提升 查找函数对比:findall,search,match Linux backtrace() git本地协同
python2处理表格文件按照规则多行输出(中文路径,print)
Lunais · 2021-06-21 · via 博客园 - Lunais
 1 #!/usr/bin/python
 2 # -*- coding: UTF-8 -*-
 3 
 4 #python2支持print带入参
 5 from __future__ import print_function
 6 # python2使用utf-8编码解决中文路径问题
 7 from __future__ import unicode_literals 
 8 import os, sys, json, getopt, re
 9 #在python3中不需要设置也可以支持中文路径
10 reload(sys) 
11 sys.setdefaultencoding('utf-8')
12 
13 class printTableFunc(object):
14     def __init__(self, file, fileList = [], fileDir = {}):
15         self.process(file, fileList, fileDir)
16                    
17     def process(self, file, fileList, fileDir):
18         with open(file, 'rw') as fr:
19             # print fr.name
20             data = fr.readline()
21             print ("//"+data)
22             lines = fr.readlines()
23             for line in lines:
24                 line = line.strip('\n\r')
25                 # print line
26                 fileList.append('{'+line+'}, ')
27         fr.close()
28 
29 if __name__ == '__main__':
30     tableFile = '/测试中文路径/test.csv'
31     fileList = []
32     fileDir = {}
33 
34     printTableFunc(tableFile, fileList, fileDir)
35     i = 0
36     for file in fileList:
37         i = i + 1
38         if (0 == i % 7):
39             print(file)
40         else:
41             print(file, end='')

 以上代码风格有点C,后面再写一个正则表达式的实现练习一下,mark一下20210623