• Cursos
  • Compilador de Código
  • Debatir
  • Precios
  • Teams
Menu
0

Can we use readlines function to count no. of new line character in files in python?

Question is regarding file in python.

python
30th Jan 2020, 11:44 AM
Amey Godse
Amey Godse - avatar
1 Respuesta
+ 5
with open('file.txt') as f: print(len(f.readlines()))
30th Jan 2020, 11:55 AM
Aymane Boukrouh
Aymane Boukrouh - avatar

¿Tienes a menudo preguntas como esta?

Aprende gratis de forma más eficaz

  • Introducción a Python

    7,1M de estudiantes

  • Introducción a Java

    4,7M de estudiantes

  • Introducción a C

    1,5M de estudiantes

  • Introducción a HTML

    7,5M de estudiantes

Ver todos los cursos
En tendencia hoy
Hello! I’m 15 and I want to learn programming to become a web developer. Any advice?
0 Votes
help string permutation
0 Votes
Code is wrong somehow, I need help!
0 Votes
Is the Python Developer course the final course of Python?
0 Votes
@sololearn Python
1 Votes
Can you give me some advice on what project I can start with today to practice HTML, CSS, and JavaScript?
0 Votes
APP FREEZING
0 Votes
Newb
0 Votes
I am asking for your help, I need to optimisate my code.
0 Votes
Building an AI Call Tracking & Routing System — Anyone tried it?
0 Votes