- 浏览: 1777422 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (723)
- IE 国际化 (1)
- java (310)
- python (52)
- Spring (101)
- eclipse (43)
- birt (10)
- exe4j (1)
- ActiveMQ (3)
- HornetQ (7)
- Ext (16)
- Linux (50)
- james (1)
- mail (3)
- 经验 (288)
- tomcat (5)
- Netty (3)
- ant (6)
- rsync (2)
- MD5 (3)
- 正则表达式 (3)
- 非技术 (59)
- mysql (28)
- sftp (1)
- Commons (2)
- oracle (3)
- vsftp (1)
- jdoc (1)
- socket (3)
- SEDA (2)
- UUID (1)
- quartz (7)
- javascript (50)
- sql (5)
- array (3)
- POI (3)
- redis (2)
- junit (4)
- 二维码 (1)
- jdk (8)
- h2 (6)
- maven (37)
- JVM (5)
- html (4)
- css (1)
- excel (4)
- myeclipse (2)
- scala (0)
- jQuery (5)
- log (10)
- slf4j (2)
- log4j (9)
- REST (15)
- guava (18)
- Joda-Time (7)
- ini4j (1)
- 配置文件 (2)
- lucene (1)
- database (3)
- curator (2)
- zookeeper (3)
- 并发 (2)
- jetty (6)
- ehcache (5)
- windows (1)
- protobuf (1)
- select2 (2)
- easyui (10)
- Freemarker (1)
- Filter (1)
- twisted (1)
- DateTime (11)
- mockrunner (1)
- DataSource (4)
- ajax (1)
- shell (18)
- powermockito (5)
- json (5)
- lombok (1)
- jointjs (1)
- cookie (1)
- mybatis (11)
- 加密解密 (2)
- 安全 (2)
- web (1)
- notepad++ (3)
- mac (48)
- sublime (14)
- git (7)
- docker (10)
- jar (1)
- gson (5)
- ubuntu (3)
- 模式 (1)
- neo4j (2)
- elasticsearch (1)
- OmniGranffle (1)
- ASCII (1)
- jdbc (3)
- kafka (1)
- MQ (1)
- chrome (3)
- 华为 (1)
- 路由器 (1)
- api (2)
- 架构 (1)
- 设计模式 (1)
- pip (4)
- springboot (48)
- 数据库 (4)
- thread (1)
- java.thread (1)
- sqlite (1)
- postman (1)
- springboot-actuator (2)
- jwt (1)
- token (1)
- brew (9)
- vim (1)
- virtualbox (1)
- Swagger (1)
- spring-retry (3)
- 调度 (1)
- item2 (5)
- graph (12)
- jgrapht (12)
- tuple (1)
- hadoop (5)
- curl (1)
- 算法 (3)
- Jekyll (1)
- github (1)
- ssh-keygen (1)
- zip (2)
- http (2)
- RestTemplate (8)
- 文件处理 (2)
- XStream (1)
- XML (3)
- JAXB (1)
- 笛卡尔积 (2)
- hive (1)
- 搜狗输入法 (1)
- 常用java类 (2)
- nginx (1)
- log4j2 (1)
- drawio (2)
- 安卓 (1)
- 小米 (1)
- okhttp (1)
- requests (1)
- 格式化 (2)
- MySQL Workbench (1)
- 分布式 (1)
- zip4j (1)
- hbase (5)
- hikari (1)
- javers (1)
- pydatetime (4)
- pyassert (1)
- pylog (2)
- tree (2)
- download (1)
- zeppelin (1)
- utils (2)
- wget (1)
- 鼠标 (1)
- 位运算 (2)
- open api (1)
- 域名 (1)
最新评论
-
youngcoder:
haohaohao~
Spring cache 注解功能不起作用的解决方案 -
kanpiaoxue:
lixz 写道有具体实例demo吗好多年前写的了。你还是去官网 ...
spring batch(一):基础部分 -
lixz:
有具体实例demo吗
spring batch(一):基础部分 -
BuDongOrz:
...
Spring MVC controller 读取配置文件 -
hvang1988:
理解错了,原来还是计数,不是时间
spring batch(二):核心部分(1):配置Spring batch
python 3.*以前的版本,打印汉字等亚洲字符,需要在.py文件的开头额外添加编码信息。这里我就是简单的写了一个添加utf-8编码的工具方法,方便自己使用。其实,在 pyDev IDE里面,可以给每个文件定义开头的。我的博客里面有。这里就给出一个可以遍历指定目录里面所有.py的文件,没有添加编码的,全部添加编码。
#-*-coding:utf-8-*- ''' Created on 2012-4-22 @author: kanpiaoxue ''' from string import strip import os class PythonUtil(object): UTF8_STRING = '#-*-coding:utf-8-*-' def __init__(self): pass def addAddUtf8(self, inputFile): needUtf8ListFiles = self.needUtf8(inputFile) count = len(needUtf8ListFiles) if count > 0: for tmpFile in needUtf8ListFiles: print tmpFile, ' need to add ', self.UTF8_STRING readFile = None writeFile = None try: readFile = open(tmpFile, 'r') lines = readFile.readlines() lines.insert(0, self.UTF8_STRING + '\n') writeFile = open(tmpFile, 'w') writeFile.writelines(lines) print 'add ', self.UTF8_STRING, ' to ', tmpFile finally: if readFile is not None: readFile.close() if writeFile is not None: writeFile.flush() writeFile.close() print '\n-------------- result report begin --------------' if count > 0: print 'add ', self.UTF8_STRING, ' to ', count, ' files successfully.' else: print 'there are not any files needing to add ', self.UTF8_STRING print '-------------- result report end --------------\n' def needUtf8(self, inputFile): needUtf8ListFiles = [] if not os.path.isdir(inputFile): print '[', inputFile, '] is not a valid folder. Please check it.' return needUtf8ListFiles for root, dirs, files in os.walk(inputFile): for name in files: f = os.path.join(root, name) if f.endswith('.py') : tmpFile = None try: tmpFile = open(f, 'r') lines = tmpFile.readlines() if len(lines) > 0: if strip(lines[0]) != self.UTF8_STRING: needUtf8ListFiles.append(f) else: needUtf8ListFiles.append(f) finally: if tmpFile is not None: tmpFile.close() return needUtf8ListFiles if __name__ == '__main__': f = r'E:\workspace_python' pythonUtil = PythonUtil() pythonUtil.addAddUtf8(f)
发表评论
-
wget下载文件夹
2021-01-14 13:23 754使用wget下载文件夹的功能和python快速启动HT ... -
python处理时间
2021-01-08 12:55 221from datetime import dat ... -
python的sys.exit()的0-255问题
2020-08-14 16:42 636最近写了一个python脚本用到了sys.exit( ... -
如何使用Python SimpleHTTPServer提供UTF-8编码的文件?
2020-08-13 21:15 547如何使用Python SimpleHTTPServer提供 ... -
python计算方法耗时
2020-07-21 10:18 514from datetime import dat ... -
python2的datetime格式化
2020-06-03 16:08 313官网地址: https://docs.python.o ... -
python的简易教程
2020-05-20 09:56 269《Learn Python Programming》: ... -
python的log文件回滚
2020-05-18 15:03 333python生成按照文件大小进行回滚的日志 ... -
python的assert断言
2020-05-15 11:09 329举例: assert len(lists) & ... -
python的datetime
2020-05-15 10:56 259参考文章: https://www.programi ... -
python打印日志到标准输出
2020-04-30 12:17 575import logging ... -
python需求文件requirements.txt的创建及使用
2020-03-25 21:34 959迁移python环境是很麻烦的事情,需要精准的安装一 ... -
python运行os.system(cmd)的退出问题
2020-02-26 10:02 2231发现之前有人写了一个python的脚本使用os.sy ... -
使用python自带的http模块(urllib2)发送POST请求
2019-12-30 15:20 787python的requests的package非常好用 ... -
python获得机器名和IP地址
2019-12-27 16:34 325import socket # ... -
python处理xml
2019-11-27 16:57 304使用python的内置功能 xml.etree.Elemen ... -
python requests的例子
2019-10-08 15:03 322# get import requests url ... -
pip一次安装多个package
2019-07-01 15:45 938在一个pip的命令行里面可以同时指定安装多个package。 ... -
pip加速
2019-06-27 20:17 502原文:https://blog.csdn.net/z ... -
python SimpleHTTPServer和SimpleXMLRPCServer
2018-11-19 22:15 1107python有2个非常有用的内置服务器: Simp ...
相关推荐
393 | [UTF-8 Validation](https://leetcode.com/problems/utf-8-validation/) | [C++](./C++/utf-8-validation.cpp) [Python](./Python/utf-8-validation.py) | _O(n)_ | _O(1)_ | Medium | | 401 | [Binary Watch]...
内容如下:[mysqld] bind-address = 10.32.24.255 default-storage-engine = innodb innodb_file_per_table = on max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8。...
PEP 529: Change Windows filesystem encoding to UTF-8 PEP 528: Change Windows console encoding to UTF-8 PEP 520: Preserving Class Attribute Definition Order PEP 468: Preserving Keyword Argument ...
Python是一种广泛使用的高级编程语言,以其简洁明了的语法和强大的功能著称。本文将深入探讨Python中的常用词汇和语法。 一、交互式环境与print输出 Python的交互式环境允许程序员快速测试代码片段,而`print`是...
graph = {task: set(deps) for task, deps in dependencies.items()} no_deps = deque(task for task, deps in graph.items() if not deps) order = [] while no_deps: current = no_deps.popleft() order....
- 修改数据库:`ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;` - 删除数据库:`DROP DATABASE database_name;` - 创建表:`CREATE TABLE table_name (column1 datatype, column2 ...
DEFAULT_CHARSET = 'utf-8' ``` 3. **数据库字符集设置**:登录到数据库后执行以下命令,确保数据库的字符集设置为`utf8`。 ```sql SET character_set_client = utf8; SET character_set_connection = utf8; ...
Python常用英文单词 Python是一种广泛使用的编程语言,了解Python常用英文单词对于提高编程效率和理解代码至关重要。下面是Python常用英文单词的总结: 一、交互式环境与print输出 * print:打印/输出 * coding:...
default-character-set=utf8 [mysqld] default-storage-engine=INNODB character_set_server=utf8 ``` - 复制`mysql.server`到`/etc/init.d/mysql`: ```bash cp /usr/local/mysql/support-files/mysql....
mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all on zabbix.* to 'zabbix'@'%' identified by 'zabbix'; mysql> flush privileges; ``` 初始化数据库 我们可以使用以下命令...
Python, for example, runs on MacOS, Unix, Windows and PalmOS. Rebol runs on even more. AppleScript is a standard part of every MacOS revision since 8.0 and is even included in MacOS X. Perl is ...
Python是一种广泛使用的高级编程语言,以其易读性强、语法简洁而受到欢迎。在学习Python时,掌握一些核心的英语词汇是必要的。以下是一些关键概念的详细解释: 1. **interpreter**:Python解释器是执行Python代码的...
Python是一种广泛使用的高级编程语言,以其易读性、简洁的语法和丰富的库支持而闻名。在学习Python时,了解一些常用的英文单词对于理解和编写代码至关重要。以下是一些关键概念的详细解释: 一、交互式环境与print...
ALTER DATABASE database1 CHARACTER SET utf8; ``` 这将将 `database1` 数据库的编码修改为 UTF-8。 6. 查看数据库结构 查看数据库结构是通过 `DESC` 语句实现的。例如: ```sql DESC database1.student; ``` 这...
若需要指定编码,例如UTF-8: ``` create database test1 default character set utf8 collate utf8_general_ci; ``` 7. 删除数据库: ``` drop database database_name; ``` 8. 插入数据到表中: ``` insert into...
CREATE DATABASE python27 CHARACTER SET utf8; ``` 查看创建数据库的完整语句: ```sql SHOW CREATE DATABASE python27; ``` 切换到某个数据库: ```sql USE python27; ``` 删除数据库: ```sql DROP DATABASE ...
Set<Character> set = new HashSet(); for (int i = 0; i (); i++) { set.add(s.charAt(i)); } return set.size() == 10; } ``` **答案解析:** - 通过暴力法或Set集合方法,可以得出维纳当时的年龄是18岁。 ...
### Python编程必备英语知识点详解 #### 一、交互式环境与 print 输出 1. **print**: 打印或输出信息到屏幕。例如:`print("Hello, World!")`。 2. **coding**: 编码,指将源代码转换成计算机可以理解的语言的过程...
- **Influences:** Influenced by earlier languages like BCPL and B, and later influenced languages like C++, Java, and Python. #### Why use C? C is chosen for its simplicity, efficiency, and ...