Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receive date parameter conversion confusion[Receive Operation not String] #86

Closed
shaozhipeng opened this issue Jun 23, 2017 · 4 comments

Comments

@shaozhipeng
Copy link

import fire
class Test:
def init(self):
print('初始化成功')

def stat(self, daystr='1970-01-01'):
    print('开始--%s' % daystr)

if name == 'main':
fire.Fire(Test)

命令行测试并输出结果:
$ python3 tests.py stat 2016-12-10
初始化成功
开始--1994
$ python3 tests.py stat 2016-12-09
初始化成功
开始--2016-12-09
$ python3 tests.py stat 2017-01-09
初始化成功
开始--2017-01-09
$ python3 tests.py stat 2016/12/10
初始化成功
开始--2016/12/10
$ python3 tests.py stat xxx
初始化成功
开始--xxx
$ python3 tests.py stat 中文
初始化成功
开始--中文
$ python3 tests.py stat 2017-12-10
初始化成功
开始--1995
$ python3 tests.py stat 2017-12-11
初始化成功
开始--1994
$ python3 tests.py stat 2017-12-12
初始化成功
开始--1993
$ python3 tests.py stat 2016-12-12
初始化成功
开始--1992
$ python3 tests.py stat 1995-10-10
初始化成功
开始--1975
$ python3 tests.py stat 1995-11-10
初始化成功
开始--1974

@shaozhipeng shaozhipeng changed the title Receive date parameter conversion confusion Receive date parameter conversion confusion[Receive Operation not String] Jun 23, 2017
@shaozhipeng
Copy link
Author

shaozhipeng commented Jun 23, 2017

When month >= 10 or day >= 10 then the result is year minus month and minus day

@shaozhipeng
Copy link
Author

issue resoved '"1995-11-10"'

@shaozhipeng
Copy link
Author

got it
$ python example.py 10
int
$ python example.py "10"
int
$ python example.py '"10"'
str
$ python example.py "'10'"
str
$ python example.py "10"
str

@dbieber
Copy link
Member

dbieber commented Jun 23, 2017

I'm glad you were able to answer your own question :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants