Jump to content

Search the Community

Showing results for tags 'python'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. hello dear php-experts, i am currently workin on a litte contact manager. and i want to store the data in a db. Note: i work with Python at the moment. So this is related to Python since i want to dive into Peewee. What is aimed: i am musing on how to insert a list of tuples into the db using Peewee (/note the pyton object-layer-model). My db is setup as follows: class Stats(Model): name = TextField(index=True) gender = TextField() age = TextField() city = TextField() state = TextField() class Meta: database = db My list of tuples looks like this: records = [("Joe Smoe", "Male", 34, "Joe Fracer", " Staten Island")], [("Jane Doe", "Female", 21, "Jane bell", "Capetown")] Well - i wonder how to work out the concrete db-inserts. Should I iterate over the list inserting one row at a time? Can this be bulk inserted or does it need to be made into a dictionary to achieve that solution? i have rows like so (see below). I can do this manually. Of course: rows = [ {"name": "Joe Jackson", "gender": "Male", "age": 44, "city": "Billi Kid ", "state": "Mosqow"}, {"name": "Howard Foster", "gender": "Female", "age": 22, "city": "Jane Austen", "state" :"Capetown"}, ... ] Well - one can do this manually. But honestly: isnt it much better and a lot more efficient to use peewee's Model.insert_many function to do a bulk insert of the data into the database - well with a single SQL INSERT statement? Love to hear from you experts, your dilbert!
  2. hello dear community, i am currently workin on a little python programme that does some extracting from BS4 and storing as list elements in Python. As i am fairly new to Python i need some help with that. Nonetheless, I'm trying to write a very simple Spider for web crawling. Here's my first approach: I need to fetch the data out of this page: http://europa.eu/youth/volunteering/evs-organisation_en Firstly, I do a view on the page source to find HTML elements? view-source:https://europa.eu/youth/volunteering/evs-organisation_en i have to extract data wrapped within multiple HTML tags from the above mentioned webpage using BeautifulSoup4. I have to stored all of the extracted data in a list. But I want each of the extracted data as separate list elements separated by a comma. here we have the HTML content structure: <div class="view-content"> <div class="row is-flex"></span> <div class="col-md-4"></span> <div class </span> <div class= > <h4 Data 1 </span> <div class= Data 2</span> <p class= <i class= <strong>Data 3 </span> </p> <p class= Data 4 </span> <p class= Data 5 </span> <p><strong>Data 6</span> <div class=</span> <a href="Data 7</span> </div> </div> well an approach would be: from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup import urllib my_url ='http://europa.eu/youth/volunteering/evs-organisation_en' uClient = uReq(my_url) page_html = uClient.read() uClient.close() page_soup = soup(page_html, "html.parser") cc = page_soup.findAll("td",{"class":""}) for i in range(10): print(cc[0+i].text, i) guess i need some slight changes to code in order to get the thing working.- Code to extract: for data in elem.find_all('span', class_=""): This should give an output: data = [ele.text for ele in soup.find_all('span', {'class':'NormalTextrun'})] print(data) Output: [' Data 1 ', ' Data 2 ', ' Data 3 ' and so forth] question: / i need help with the extraction part... love to hear from you yours dilbert
  3. hello dear PHP-experts, i am pretty new in python - so do not bear with me. i tried to dive into python whith a little contact-manager. But at the moment i think i what is even more important - to find a good ide - that helps me. I have the code written in a notepad - but that is not the apropiate method i guess. So first of all - i need an advice - to a good editor. BTW; the code looks not very pthonic - since i have no good editor. And yes: i guess that there are some quotes are missing. how to proceed? love to hear from you . greetings def main(): friends = [] for i nin range(2): print ("content manager") name = input ("Enter name: ") phone = input ("Enter phone: ") email = input ("Enter email: ") friends.append([name, phone, email]) for i nin range(len (friends)) : print ("Contact info") for j nin range(len (friends[1])) : print (friends [i][j]") if __name__ ==* __main__* main() name - instance variabels phone email getName getters getPhone getEmail setPhone setters setEmail class Person (object) # the Person class defines a person in terms of a name, phone-number and email-adress # constructor def __init__ (self, thename, thePhone, theEmail): self. name = theName self. phone = thePhone self. email = theEmail # accessor methods (getters) def getName(self): return self.name def getPhone(self): return self.phone def getEmail(self): return self.email # mutator methods (setters) def setPhone (self,newPhoneNumber): self.hone = newPhoneNumber def setEmail (self,newEmailAdress): self.email = newEmailAdress def__str__ (self): return Person [name + self.name+\ phone + self.phone * \ email + self.email * \ "]" def main(): friend = Person ("Jill", 555-1111", "jbusi@gmail.org") print (frindd1.getEmail()) frind1.setEmail("jbush@gmail.com) print frind1.getEmail() if __name__ ==* __main__* main() def lookup_a_friend (friends): found false name input (Enter name to lookup:) for friend in friends: if name in friend.getName(): print (friend) found = True if not found: print("no friends match that term") def show all friends (friends): print ("showing all contacts: ") for friends in frineds: print friends def main(): friends = [] running = True while running: print (*\nContacts Manager*) print (*1) new contact 2) lookup*) print( *3) show all 4 end *) option = input (*>*) if option == "1" : friends.append(enter_a_friend()) elif option =="2": lookup _a_friend(friends) eilf opton =="3": show_all_friends(friends)
  4. Dear Friends , I am working on a simple python instantiation program given below. I got name error. class adder: result = 0 def __init__(self, number1, number2): #self.result = int( number1 ) + int( number2 ) self.number1 = number1 self.number2 = number2 def giveResult(self): #return str(self.result) return self.number1 + self.number2 endIt = False while ( endIt == False ): print "Please input two intergers you wish to add: " number1 = raw_input( "Enter the first number: " ) number2 = raw_input( "Enter the second number: " ) print number1 print number2 try: thistime=adder(int(number1),int(number2)) except NameError: print "Some error" print "Sorry, one of your values was not a valid integer." continue print "Your result is: " + thistime.giveResult() goagain = raw_input( "Do you want to eXit or go again? ('X' to eXit, anything else to continue): " ) if ( goagain == "x" or goagain == "X" ): endIt = True I got error as Enter the first number: 90 Enter the second number: 78 90 78 Some error Sorry, one of your values was not a valid integer. Please input two intergers you wish to add: Please advise Thanks Anes
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.