创建文件夹并解决解决unicode和ASCII码转换的问题
# -*- coding: UTF-8 -*-
import sys
import time
import os #解决unicode和ASCII码转换的问题
reload(sys) #解决unicode和ASCII码转换的问题
sys.setdefaultencoding('utf8') #解决unicode和ASCII码转换的问题
context = '''hello world'''
f = open("hello.txt", 'a+')
f.write(context)
f.close()
date1 = time.strftime("%Y%m%d", time.localtime())
date2 = "第"+time.strftime("%U", time.localtime())+"周"
date3 = "星期"+ time.strftime("%w", time.localtime())
print date1
print date2
print date3
date1 = str(date1)+str(date2)+str(date3)
# date1 = date1.encode(unicode)
path = ur"D:\工作目录\"
# print date1
# path = path + path1 + date1
path = str(path) + str(date1)
# print path
os.mkdir(path.encode('gbk'))
#os.mkdir(path.encode('gbk'))
# print path.decode('gb2312')
#path.decode('gb2312')
# path = path + date1
# print path
# os.mkdir(r'd:\工作目录\temp')
# lll = r'd:\Hello\Time'+date1
# print lll
# os.mkdir(lll)
# print path
# os.mkdir(path)
创建文件夹并解决解决unicode和ASCII码转换的问题的更多相关文章
- ubuntu下无法在目录下创建文件夹,权限不足解决办法
问题详情:偶然在根目录创建文件夹的时候,突然显示错误,当时很惊讶,以前没遇见过这样的问题.当时界面是这样的. 用了一个 cd / 命令从用户磁盘跳到了根目录 使用 mkdir 命令准备创建一个文件夹, ...
- Eclipse/MyEclipse向HDFS中如创建文件夹等操作报错permission denied解决办法
不多说,直接上干货! 问题现象 当执行创建文件的的时候, 即: String Path = "hdfs://host2:9000"; FileSystem fileSystem = ...
- lr cc安装后提示“内部出现错误,无法创建文件夹”的解决办法
好多人在使用lr过程中提示“内部出现错误,无法创建文件夹”,今天MacW小编给大家带来了解决的方法,一起来看看吧! 1.此问题主要是用户权限的问题. 下载这个shell 脚本,此 shell 脚本可自 ...
- webstorm无法显示左边文件夹目录的解决方法
webstorm无法显示左边文件夹目录的解决方法 方法一 view-->Tool Windows-->Project 就可以显示或者关闭 方法二 1.删除webstorm的配置文件夹 2. ...
- PHP创建文件命名中文乱码解决的方法
PHP创建文件命名中文乱码解决的方法 <pre>iconv('utf-8', 'gbk', $dir); </pre> 因为系统环境是gbk 所以里面的字符也要gbk 编码一致 ...
- PIP无法使用,script文件夹为空解决
[问题]环境变量已配置,但pip.pip3无法使用,且script文件夹为空解决: 一.安装pip3 python -m ensurepip 运行完之后就pip3有了: 二.安装pip python ...
- 如何异步创建文件夹(node)
模块fs作为node的核心模块之一,支持本地文件操作的接口,几乎对于所有的操作都提供同步和异步两种方案.例如,创建文件夹有mkdir和mkdirSync.不论对于mkdir还是mkdirSync,都需 ...
- eclipse 向HDFS中创建文件夹报错 permission denied
环境:win7 eclipse hadoop 1.1.2 当执行创建文件的的时候, 即: String Path = "hdfs://host2:9000"; FileSy ...
- java文件操作 之 创建文件夹路径和新文件
一:问题 (1)java 的如果文件夹路径不存在,先创建: (2)如果文件名 的文件不存在,先创建再读写;存在的话直接追加写,关键字true表示追加 (3)File myPath = new File ...
随机推荐
- XMLHttpRequest基础知识
XMLHttpRequest 发送请求的两个重要方法:open(method,url,async)——参数:请求方式.请求地址.请求同步/异步:send(string)——参数:使用POST方式时,填 ...
- jQuery插件教程
http://www.cnblogs.com/Wayou/p/jquery_plugin_tutorial.html 非常不错的jQuery插件教程
- c# GridView Footor列求合计
显示效果: 前台代码: <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" ...
- 手机三种SIM卡 你所不知道的剪卡“秘密”
SIM卡物理尺寸的发展是逐渐轻薄化,尺寸逐渐缩小的一个过程,最早手机中的卡都是2FF,2003年国际标准提出3FF,当前很多终端都使用这种形态的卡,4FF在2011年的国际标准会议中提出,2012年纳 ...
- SQL Server 2008空间数据应用系列三:SQL Server 2008空间数据类型
原文:SQL Server 2008空间数据应用系列三:SQL Server 2008空间数据类型 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server ...
- N-Queens II 解答
Question Follow up for N-Queens problem. Now, instead outputting board configurations, return the to ...
- Implement Trie (Prefix Tree) 解答
Question Implement a trie with insert, search, and startsWith methods. Note:You may assume that all ...
- Word Ladder 解答
Question Given two words (beginWord and endWord), and a dictionary's word list, find the length of s ...
- Minimum Size Subarray Sum 解答
Question Given an array of n positive integers and a positive integer s, find the minimal length of ...
- hdu 2079 选课时间_母函数
题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using name ...