Playing music using python [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a small piece of coding that I would like to use to play either mp3 files or wave files. Im not sure how to do this.
By the way I am fairly new to programming and am using python 3.2.
All help would be much appreciated. Thanks

You could use http://www.pygame.org/news.html
Then something like this using pygame.mixer.music:
import pygame
pygame.mixer.init()
pygame.mixer.music.load("myfile.mp3")
pygame.mixer.music.play()

Related

control flow for loops that identify chapters in a book [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to write a function that loops through a .txt file of a books and identifies chapters. I am using the appearance of more than one \n in a row followed by one line of non \n text to signify a new chapter. How would you guys structure the loops to do this? I personally am using python, but you should feel free to keep your answers as abstract as possible.
chapters = filter(None,map(str.strip,text.split("\n\n")))
you could also do it with re using Stevens answer from the comments

Python, Using regex to read a password [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am aware that you can use the pwd module on python to extract passwd structures for use; however, my question is as such:
if I read into my program a line such as
blah1:tVNIsQ0yDrLxM:16009:0:99999:7:::
or
blah2:$6$WVsjYh8e$5r2wvIaeiFI6CCFRw6stfbah0Q.wrcKITdmEDCvG2cNC4fXkVbgRiOdeCdU.WeD1NIyzLh/sXycXQFEQcNWsv/:16009:0:99999:7:::
how would I read just the section that reads "tVNIsQ0yDrLxM"?
Thank you
As long as there's no extra colons in there, this should work:
password = hash.split(':')[1]
split

traceroute syntax error in python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am new to python and am now learning about 'traceroute'. I don't exactly understand how this works. If I am typing the traceroute in python command line, I receive a syntax error:
traceroute www.somewebsite.com
I receive a syntax error pointing to ^www
Am I misunderstanding or doing something wrong? I'm trying to work on this in practice from a book reading assignment.
Can someone explain what traceroute is exactly?
Your help is appreciated, thank you.
This is not supposed to work, because python does not understand terminal/cmd commands. So you need to use os.system in this case:
So, in your case:
import os
os.system('traceroute www.somewebsite.com`)
In windows its tracert not traceroute.

Send JSON data to the front end in Flask [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Just wondering how can you send JSON data to the front end of a web app using Flask. Don't have that much experience with it, just looking for some ideas?
Create a dictionary Dict.
If Dict is your dictionary, you can just do
return flask.jsonify(**Dict)

Creating a POS (Point of Sale) system with python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to create a functional POS system with python, I just don't know where to begin. I am fluent in the language, but I have never done any web development with python. Can someone point me in the right direction, how to incorporate python into html and mysql?
Not sure what POS means, is that Point of Sale?
For web development, people in Python land tend to go with Django and Flask as they are the most popular.
https://www.djangoproject.com/
and
http://flask.pocoo.org/

Categories

Resources