Comments (4)
import time
epoch = time.time()
seconds_in_a_day = 24 * 60 * 60
seconds_in_an_hour = 60 * 60
seconds_in_a_minute = 60
days = epoch // seconds_in_a_day
hours = (epoch % seconds_in_a_day) // seconds_in_an_hour + 8
minutes = (epoch % seconds_in_a_day) % seconds_in_an_hour // seconds_in_a_minute
seconds = (epoch % seconds_in_a_day) % seconds_in_an_hour % seconds_in_a_minute
print("%s: %s: %s: %s" %(days, hours, minutes, seconds))
print("Beijing Current time is %d: %d: %d: %d" %(days, hours, minutes, seconds"))
from thinkpython2.
import time
epoch=time.time()
#606024=86400
total_sec = epoch % 86400
#60*60
hours = int(total_sec/3600)
total_minutes = int(total_sec/60)
mins = total_minutes % 60
sec = int(total_sec % 60)
days=int(epoch/86400)
print("The Current time is",hours,':',mins,':',sec)
print("Days since epoch:", days)
from thinkpython2.
Looks like the extra closing quote is not needed on final print statement.
from thinkpython2.
import time mytime=time.time() seconds=mytime mins=mytime/60 hrs=mins/60 days=hrs/24 weeks=days/7 months=weeks/4 years=months/12 print(seconds,mins,hrs,days,weeks,months,years)
from thinkpython2.
Related Issues (20)
- exercise 17.2: GoodKangaroo.py has its own pitfall
- sharp-sign (#) filtered out in pronounce.py HOT 2
- Bug in has_duplicates.py HOT 1
- Some punctuation, not sure it's a bug or just a habit of expression HOT 1
- do_four.py IS WRONG HOT 3
- simple grid.py HOT 1
- Exercise 18.1 mentions "UML" when UML is not mentioned elsewhere in the book or chapter HOT 1
- Exercise 9.7 cartalk1.py HOT 1
- Ghost 👻👻👻👻 Game
- chapter 2 and section 2.5 HOT 2
- Epub version of 2.4.0
- next iteration of grid.py HOT 1
- Unclear Question
- Suddenly confusing passage on page 169, 17.11
- Markov.py need to change file read encoding to utf8 - among other issues
- Dict is now ordered. Maybe the book should be updated? HOT 4
- exercise 8.3: every other HOT 4
- section 17.2: faulty double zero HOT 2
- section 16.2: built-in function name used as local variable name
- glossary 17.2: object-oriented programming: possible too restrictive definition
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thinkpython2.